<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}剪藏应用{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('index') }}">
                <i class="fas fa-bookmark"></i> 剪藏应用
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('index') }}">
                            <i class="fas fa-home"></i> 首页
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="#" onclick="showAddModal()">
                            <i class="fas fa-plus"></i> 添加收藏
                        </a>
                    </li>
                </ul>
                <form class="d-flex">
                    <input class="form-control me-2" type="search" placeholder="搜索收藏..." id="searchInput">
                    <button class="btn btn-outline-light" type="button" onclick="searchCollections()">
                        <i class="fas fa-search"></i>
                    </button>
                </form>
            </div>
        </div>
    </nav>

    <main class="container mt-4">
        {% block content %}{% endblock %}
    </main>

    <!-- 添加收藏模态框 -->
    <div class="modal fade" id="addCollectionModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加新收藏</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="addCollectionForm">
                        <div class="mb-3">
                            <label for="title" class="form-label">标题 *</label>
                            <input type="text" class="form-control" id="title" required>
                        </div>
                        <div class="mb-3">
                            <label for="url" class="form-label">链接</label>
                            <input type="url" class="form-control" id="url">
                        </div>
                        <div class="mb-3">
                            <label for="source" class="form-label">来源平台</label>
                            <select class="form-select" id="source">
                                <option value="">选择平台</option>
                                <option value="微信">微信</option>
                                <option value="微博">微博</option>
                                <option value="知乎">知乎</option>
                                <option value="B站">B站</option>
                                <option value="GitHub">GitHub</option>
                                <option value="其他">其他</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="category" class="form-label">分类</label>
                            <select class="form-select" id="category">
                                <option value="">选择分类</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="tags" class="form-label">标签（用逗号分隔）</label>
                            <input type="text" class="form-control" id="tags" placeholder="例如：技术,编程,Python">
                        </div>
                        <div class="mb-3">
                            <label for="content" class="form-label">内容描述</label>
                            <textarea class="form-control" id="content" rows="4"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="saveCollection()">保存</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 编辑收藏模态框 -->
    <div class="modal fade" id="editCollectionModal" tabindex="-1">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">编辑收藏</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="editCollectionForm">
                        <input type="hidden" id="editId">
                        <div class="mb-3">
                            <label for="editTitle" class="form-label">标题 *</label>
                            <input type="text" class="form-control" id="editTitle" required>
                        </div>
                        <div class="mb-3">
                            <label for="editUrl" class="form-label">链接</label>
                            <input type="url" class="form-control" id="editUrl">
                        </div>
                        <div class="mb-3">
                            <label for="editSource" class="form-label">来源平台</label>
                            <select class="form-select" id="editSource">
                                <option value="">选择平台</option>
                                <option value="微信">微信</option>
                                <option value="微博">微博</option>
                                <option value="知乎">知乎</option>
                                <option value="B站">B站</option>
                                <option value="GitHub">GitHub</option>
                                <option value="其他">其他</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="editCategory" class="form-label">分类</label>
                            <select class="form-select" id="editCategory">
                                <option value="">选择分类</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label for="editTags" class="form-label">标签（用逗号分隔）</label>
                            <input type="text" class="form-control" id="editTags" placeholder="例如：技术,编程,Python">
                        </div>
                        <div class="mb-3">
                            <label for="editContent" class="form-label">内容描述</label>
                            <textarea class="form-control" id="editContent" rows="4"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="updateCollection()">更新</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="{{ url_for('static', filename='js/app.js') }}"></script>
</body>
</html>

